<?php

namespace App\Jobs\Push;

use Exception;
use App\Facades\Push;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Log;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * 删除标签以及标签和设备的绑定关系
 *
 * Date: 2018/6/4
 * @author George
 * @package App\Jobs\Push
 */
class DeleteTag implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

	/**
	 * @var string
	 * Date: 2018/6/4
	 * @author George
	 */
    protected $tag;

	/**
	 * DeleteTag constructor.
	 * @param string $tag
	 */
    public function __construct(string $tag)
    {
    	$this->tag = $tag;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
		try {
			Push::device()->deleteTag($this->tag);
		} catch (Exception $exception) {
			Log::error($exception);
		}
	}
}
